package cn.shiva.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * @author shiva   2021/10/16 15:26
 */
@Slf4j
@Component
public class StreamFilter implements Filter {
    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {

        WrappedHttpServletRequest requestWrapper = new WrappedHttpServletRequest((HttpServletRequest) request);

        String params = requestWrapper.getRequestParams();
        log.info("【请求链接】：{}，【请求参数】：{}", ((HttpServletRequest) request).getRequestURI(), params);

        chain.doFilter(requestWrapper, response);
    }
}
